//
//  DiagnosisTableViewCell.m
//  AnXin100
//
//  Created by Sakura on 2018/11/10.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "DiagnosisTableViewCell.h"

@interface DiagnosisTableViewCell ()

@property (nonatomic, strong) UIImageView *userImage;

@property (nonatomic, strong) UILabel *userNameLabel;

@property (nonatomic, strong) UILabel *contentLabel;

@property (nonatomic, strong) UIImageView *problemImage;

@property (nonatomic, strong) UIButton *diagnosisBtn;

@property (nonatomic, strong) UILabel *timeLabel;

@property (nonatomic, strong) UILabel *countLabel;

@property (nonatomic, strong) UILabel *priceLabel;

@end

@implementation DiagnosisTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCell];
    }
    return self;
}

- (void)creatCell {
    
    _userImage = [UIImageView new];
    _userImage.layer.cornerRadius = 25;
    _userImage.layer.masksToBounds = YES;
    _userImage.image = [UIImage imageNamed:@"xy.jpg"];
    [self.contentView addSubview:_userImage];
    
    _userNameLabel = [UILabel new];
    _userNameLabel.font = FONT_SIXTEEN;
    _userNameLabel.textColor = COLOR_DIV;
    _userNameLabel.text = @"薛之谦";
    [self.contentView addSubview:_userNameLabel];
    
    _contentLabel = [UILabel new];
    _contentLabel.font = FONT_FOURTEEN;
    _contentLabel.textColor = COLOR_Gray;
    _contentLabel.text = @"您好，我的葡萄叶子有点发黄，你看看是不是得霜霉病了";
    [self.contentView addSubview:_contentLabel];
    
    _priceLabel = [UILabel new];
    _priceLabel.font = FONT_FOURTEEN;
    _priceLabel.textColor = COLOR_ORG;
    _priceLabel.text = @"￥2.00元";
    _priceLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_priceLabel];
    
    _problemImage = [UIImageView new];
    _problemImage.image = [UIImage imageNamed:@""];
    _problemImage.layer.cornerRadius = 5;
    _problemImage.layer.masksToBounds = YES;
    _problemImage.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:_problemImage];
    
    _timeLabel = [UILabel new];
    _timeLabel.font = FONT_TWELVE;
    _timeLabel.textColor = COLOR_Gray;
    _timeLabel.text = @"剩余作答时长：05：30：30";
    [self.contentView addSubview:_timeLabel];
    
    _countLabel = [UILabel new];
    _countLabel.font = FONT_TWELVE;
    _countLabel.textColor = COLOR_Gray;
    _countLabel.text = @"已服务8次";
    _countLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_countLabel];
    
    _diagnosisBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _diagnosisBtn.backgroundColor = COLOR_ORG;
    _diagnosisBtn.layer.cornerRadius = 3;
    _diagnosisBtn.layer.masksToBounds = YES;
    _diagnosisBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_diagnosisBtn];
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    _userImage.frame = CGRectMake(10, 15, 50, 50);
    _userNameLabel.frame = CGRectMake(70, 15, 50, 20);
    _contentLabel.frame = CGRectMake(70, 35, SCREEN_WIDTH - 80, 20);
    _priceLabel.frame = CGRectMake(SCREEN_WIDTH - 70, 15, 60, 20);
    _problemImage.frame = CGRectMake(10, 75, SCREEN_WIDTH - 20, 180);
    _timeLabel.frame = CGRectMake(10, 265, SCREEN_WIDTH / 2 - 20, 20);
    _diagnosisBtn.frame = CGRectMake(SCREEN_WIDTH - 85, 262.5, 75, 25);
    _countLabel.frame = CGRectMake(SCREEN_WIDTH / 2 + 10, 265, SCREEN_WIDTH / 2 - 20, 20);
    
}

- (void)setType:(ServeType)type {
    if (type == NoServe) {
        
        _timeLabel.alpha = 1;
        _countLabel.alpha = 0;
        [_diagnosisBtn setTitle:@"立即诊断" forState:UIControlStateNormal];
        
    } else if (type == Serve) {
        
        _timeLabel.alpha = 0;
        _countLabel.alpha = 1;
        _diagnosisBtn.alpha = 0;

        
    } else if (type == ServeIncome) {
        
        
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
